﻿using System.ComponentModel.DataAnnotations;

namespace BankTransfer.Bank.Types.Types
{
    public class UserId
    {
        private readonly long value;
        public long Value => value;

        public UserId(long value)
        {
            Check(value);
            this.value = value;
        }
        public UserId(string value)
        {
            if (string.IsNullOrEmpty(value) || !long.TryParse(value, out long userId))
            {
                throw new ValidationException("UserId 要大于0！");
            }
            Check(userId);
            this.value = userId;
        }
        private void Check(long value)
        {
            if (value <= 0)
            {
                throw new ValidationException("UserId 要大于0！");
            }
        }
    }
}